package cn.infinite.security.core.impl;

import cn.infinite.security.configuration.SimpleSignValidateKeyStore;
import cn.infinite.security.core.SecretKeyManager;
import cn.infinite.security.error.KeyNotFoundException;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class DefaultSecretKeyManager extends SecretKeyManager<SecretKey> {

    private SimpleSignValidateKeyStore simpleSignValidateKeyStore;

    @Override
    public SecretKey getSecretByAppId(String appId) throws KeyNotFoundException {
        SecretKey secretKey = this.simpleSignValidateKeyStore.getKeyMap().get(appId);
        if (secretKey == null) {
            throw new KeyNotFoundException("未找到该应用");
        }
        return secretKey;
    }
}
